package com.cet.lxf.generic.test03;

import java.lang.reflect.Array;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-08-03 09:56
 **/
public class Main01 {
    public static void main(String[] args) {
        Pair2[] arr = new Pair2[2];
        Pair2<String>[] ps = (Pair2<String>[]) arr;

        System.out.println(ps.getClass() == Pair2[].class);

        String s1 = (String) arr[0].getFirst();
        String s2 = ps[0].getFirst();
    }
}

class Pair2<T>{
    private T first;
    private T last;
    public Pair2(T first, T last) {
        this.first = first;
        this.last = last;
    }
    public T getFirst() {
        return first;
    }
    public T getLast() {
        return last;
    }

    T[] createArray(Class<T> cls) {
        return (T[]) Array.newInstance(cls, 5);
        //return (T[]) new Object[5];
    }
}
